package cn.xiaoliu.hrm.feign;

import cn.xiaoliu.hrm.doc.CourseDoc;
import cn.xiaoliu.hrm.query.CourseDocQuery;
import cn.xiaoliu.hrm.util.AjaxResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class CourseDocFallbackFactory implements FallbackFactory<CourseDocFeignClient>{
    @Override
    public CourseDocFeignClient create(Throwable throwable) {

        return new CourseDocFeignClient() {
            @Override
            public AjaxResult courseOnline(CourseDoc doc) {
                return AjaxResult.me().setSuccess(false).setMessage("上线失败");
            }

            @Override
            public AjaxResult courseOffline(Long id) {
                return AjaxResult.me().setSuccess(false).setMessage("下线失败");
            }

            @Override
            public AjaxResult queryCourses(CourseDocQuery docQuery) {
                return AjaxResult.me().setSuccess(false).setMessage("搜索失败,请重试");
            }
        };
    }
}
